package huawei;
/*
* @Author: wanghongfucoder
* @Date:   2017-06-28 17:42:57
* @Last Modified by:   wanghongfucoder
* @Last Modified time: 2017-06-28 17:43:53
*/
import java.util.*;

public class Ipptran{
    public static void main(String[] args){
        Scanner in=new Scanner(System.in);
        while(in.hasNext()){
        String ip=in.nextLine();
        String p=in.nextLine();
        String[] ips=ip.split("\\.");
           long n=Long.parseLong(ips[0]);
        for(int i=1;i<ips.length;i++){
            n=n<<8;
            n=n+Long.parseLong(ips[i]);
        }
            System.out.println(n);
            long  a=Long.parseLong(p);
            String as=Long.toBinaryString(a);
            String ast="";
            if(as.length()<32){
                for(int j=0;j<(32-as.length());j++){
                        ast+="0";
                    }
            }
            as=ast+as;
             for(int i=0;i<as.length()-8;i=i+8){
              
            System.out.print(Integer.parseInt(as.substring(i,i+8),2)+".");
             }
             System.out.println(Integer.parseInt(as.substring(as.length()-8,as.length()),2));
   
        }
    }
}